import logging
import qrcode
import base64
from io import BytesIO
from odoo import api, fields, models
from PIL import Image,ImageFont,ImageDraw
from odoo import tools, _
from odoo.exceptions import ValidationError, AccessError
from odoo.modules.module import get_module_resource
import json
_logger = logging.getLogger(__name__)


class PosBookTable(models.Model):
    _name = 'pos.booktable'
    _description = 'Service Contract Master Record'

    # 人数
    table_people = fields.Char(string='Number Of People')
    # 时间
    table_time = fields.Datetime(u'Time',readonly=True,index=True, default=fields.Datetime.now)
    # 客户名字
    name = fields.Char(string='Customer Name')
    # 电话
    table_telephone = fields.Char(string='Phone')
    # 备注
    table_remarks = fields.Text(u'Remarks')
    # 桌子状态：店家取消、已确认订桌、客户订桌
    table_status = fields.Selection([('wait',u'Store Cancellation'),('ing',u'Confirmed Booking'),('ok',u'Customer Reservation')],u"Status",
    	readonly=True, index=True, copy=False, default='ok', track_visibility='onchange')

    config_id = fields.Many2one("pos.config", _("Belongs To POS"), readonly=True, default=lambda self: self.env.user.config_id)
    shou_id = fields.Char(u'IME')
    pos_user_id = fields.Many2one("pos.user", _("APP User"), readonly=True)
    @api.multi
    def table_determine(self):
        for contract in self:
            contract.table_status = 'ing' 
        return True

    @api.multi
    def table_cancel(self):
        for contract in self:
            contract.table_status = 'wait' 
        return True
              

